<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>南京同虹科贸，打造专业卫浴系统,TOTO专卖，TOTO洁具。</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<link href="<%=basePath%>com/njth/css/style.css" rel="stylesheet"
			type="text/css" />
		<link href="<%=basePath%>com/njth/css/layout.css" rel="stylesheet"
			type="text/css" />
		<script type=text/javascript>
        function trim(str)      
        { 
        var t = str.replace(/(^\s*)|(\s*$)/g, "");  // 用正则表达式将前后空格        
        return t.replace(/(^　*)|(　*$)/g, "");        // 用空字符串替代。      
        }   
        var xmlHttp;
        function createXMLHttpRequest(){
        if(window.ActiveXObject){
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }else if(window.XMLHttpRequest){
        xmlHttp=new XMLHttpRequest();
        } 
        }
        function validate(){

   		createXMLHttpRequest();

   		var name=document.getElementById("username").value;

   		var pass=document.getElementById("password1").value;

   		var mailname=document.getElementById("email").value;

   		var str="name="+name+"&pass="+pass+"&mailname="+mailname;

        var url="<%=basePath%>com/njth/jsp/validate.jsp";

        xmlHttp.open("POST",url,true);

        xmlHttp.onreadystatechange=callback;

   		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  

   		xmlHttp.send(str);

		}

		function callback(){

   		if(xmlHttp.readyState==4){

       	var s=xmlHttp.responseText;

       	if(trim(s)==1){

               alert("用户注册成功，即将转向首页");

               clear();

           } 

       	if(trim(s)==2){

              var ta="<font color='red'>该名称在数据库中已存在，请重新输入</font>"

              document.getElementById("res").innerHTML=ta;

              document.getElementById("username").value=""; 

            }

       	if(trim(s)==0){

              alert("产生异常");

           }

    	}

		}

		function clear(){

           document.getElementById("username").value=""; 

           document.getElementById("password1").value=""; 

           document.getElementById("password2").value=""; 

           document.getElementById("email").value=""; 

			}

		function checkPassword(e)

		{

         var ok = "1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM_.-";

         for(var i=0; i<e.length; i++)

         {

                   if (ok.indexOf(e.charAt(i))<0) 

                   {

                            return false;

                   }

         }

         return true;

		}

		function checkEmail(e){

			var ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.+@-_QWERTYUIOPASDFGHJKLZXCVBNM";

         	for(var i=0; i<e.length; i++){

                   if (ok.indexOf(e.charAt(i))<0) {

                            return false;

                   }

         }

         if(e.indexOf("@")<=0){

                   return false;

         }

         if(e.indexOf(".")<=0){

                   return false;

         }       

         if(e.indexOf("@")>e.lastIndexOf(".")){

             return false;

         }

         return true;

		}

		function validate_form()

		{

         if(document.regform.username.value == "")

         {

                   alert("用户名不能为空!");

                   return false;

         }

		if(bytelength(document.regform.username.value)<3||bytelength(document.regform.username.value)>20)

         {

                   alert("您输入的用户名不合法!");

                   return false;

         }

        if(document.regform.password1.value == "")

         {

                   alert("输入密码不能为空!");

                   return false;

         }

       if(checkPassword(document.regform.password1.value)==false)

         {

                   alert("您输入的密码不合法!");

                   return false;         

         }

         if(bytelength(document.regform.password1.value)<6||bytelength(document.regform.password1.value)>16)

         {

                   alert("您输入的密码不合法!");

                   return false;

         }

         if(document.regform.password1.value!=document.regform.password2.value)

         {

                   alert("确认密码不一致!");

                   return false;                   

         }

       if(document.regform.email.value == "")

         {

                   alert("电子邮件不能为空!");

                   return false;

         }

       if(checkEmail(trim(document.regform.email.value))==false)

         {

                   alert("您输入的Email不合法!");

                   return false;

         }

       return true;

		}

		function  bytelength(szString)

		{

         return szString.replace(new RegExp("[^\x00-\xff]", "g"), "  ").length;

		}

		function reg()

		{

         if(validate_form()==false)

             return;

         validate();

		}

</script>

	</head>
	<body id="page7">
		<div id="main">
			<!-- header -->
			<div id="header">
				<!--Valid flash version 8.0-->
				<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
					codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,24"
					width="980" height="430">
					<param name="movie"
						value="<%=basePath%>com/njth/flash/Header_f8.swf?button=5" />
					<param name="quality" value="high" />
					<param name="menu" value="false" />
					<!--[if !IE]> <-->
					<object data="flash/Header_f8.swf?button=5" width="980"
						height="430" type="application/x-shockwave-flash">
						<param name="quality" value="high" />
						<param name="menu" value="false" />
						<param name="pluginurl"
							value="http://www.macromedia.com/go/getflashplayer" />
						FAIL (the browser should render some flash content, not this).
					</object>
					<!--> <![endif]-->
				</object>
			</div>
			<!-- content -->
			<div id="content">
				<div class="bgd">
					<div class="inner">
						<div class="extra">
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/ing.jpg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/banner2.jpg" /> </a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							<a href="#"><img alt=""
									src="<%=basePath%>com/njth/images/banner3.jpg" /> </a>
						</div>
						<div class="article">
							<div class="indent">
								<h2>
									<p align=center>
										用户注册
									</p>
								</h2>
								<form name="regform" method="post" action="register.jsp">


									<p>
										<font color="#3399cc">*请输入用户名:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="username" id="username" value="" ></font> &nbsp;&nbsp;

										<span class="brown">用户名长度不能小于3.</span>
									</p>
									<p>
										<font color="#3399cc">*请输入密码:
										</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="password" id="password1" name="password1" value="">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
										<span class="brown">长度必须大于6个字符.</span>
									</p>
									<p>
										<font color="#3399cc">*再输入密码:
										</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="password" id="password2" name="password2" value="">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
										<span class="brown">俩次密码必须输入一致.</span>
									</p>
									<p>
										<font color="#3399cc">请输入真实姓名:
										</font>&nbsp;&nbsp;
										<input type="text" name="realName" value="">
											&nbsp;&nbsp; 
										<span class="brown">收货人姓名.</span>
									</p>
									<p>
										<font color="#3399cc">请输入身份证号:
										</font>&nbsp;&nbsp;
										<input type="text" name="Pid" value="">
											&nbsp;&nbsp; 
										<span class="brown">此项信息用于必要时以核实身份，一经注册，便不可更改，请如实填写！</span>
									</p>
									<p>
										<font color="#3399cc">*请选择性别:
										</font>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
										<input type="radio" name="sex" value="男" checked>
										<img src="<%=basePath%>com/njth/images/Male.gif">
											&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<input type="radio" name="sex" value="女">
										<img src="<%=basePath%>com/njth/images/Female.gif">
									</p>
									<p>
										<font color="#3399cc">请输入详细地址:
										</font>&nbsp;&nbsp;
										<input type="text" name="address" value="">
											&nbsp;&nbsp; 
										<span class="brown">收货人详细地址,以便我们及时发货.</span>
									</p>
									<p>
										<font color="#3399cc">请输入邮编:
										</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="zip" value="">
											&nbsp;&nbsp; 
										<span class="brown">请填写具体邮编.</span>
									</p>
									<p>
										<font color="#3399cc">请输入电话号码:
										</font>&nbsp;&nbsp;
										<input type="text" name="phone" value="">
											&nbsp;&nbsp; 
										<span class="brown">请填写正确的号码，以便有急事联系.</span>
									</p>
									<p>
										<font color="#3399cc">*请输入E-mail:
										</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="email" id="email" value="">
											&nbsp;&nbsp; 
										<span class="brown">请您务必填写正确的E-mail地址，便于我们与您联系.</span>
									</p>
									<p>
										<font color="#3399cc">请输入QQ号码:
										</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<input type="text" name="qq" value="">
											&nbsp;&nbsp; 
										<span class="brown">网上联系.</span>
									</p>
									<p>
										<font color="red">注:&nbsp;&nbsp;栏目前有*号的为必填选项!</font>
									</p>
									<p align="center">
										<input type="button" value="提交" onclick=reg();>
										<input type="reset" value="重填">
									</p>
									<p></p>
								</form>
								E-mail:
								<a class="link2" href="#">http://mail.njtoto.com</a>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- footer -->
			<div id="footer">
				<div class="fleft">
					NJTOTO &copy; 2009 | All right
					reserved&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					<a href="<%=basePath%>com/njth/jsp/administrator.jsp">登录</a>&nbsp;|
					<a
						href="<%=basePath%>com/njth/jsp/#">邮箱</a>
				</div>
				<div class="fright">
					<a href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img1.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img2.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img3.jpg" /> </a><a
						href="#"><img alt=""
							src="<%=basePath%>com/njth/images/footer_img4.jpg" /> </a>
				</div>
			</div>
		</div>
	</body>
</html>